#define quickread
#ifdef quickread
#include <cstdio> 
template <typename T>
inline void read(T& x)
{
    int c=getchar(), f=1; x=0;
    while(c<'0'||'9'<c) {if(c=='-') f=-1; c=getchar();}
    while('0'<=c&&c<='9') 
        x=(x<<3)+(x<<1)+c-'0', c=getchar();
    x*=f;
}
template <typename T>
inline void quickwrite(T x)
{
    if(x<0) putchar('-'), x*=-1;
    if(x>=10) quickwrite(x/10);
    putchar(x%10+'0');
}
#else 
#include <iostream>
#endif
#include <cstring>
#include <algorithm>
#include <functional>
using namespace std;
#define DEBUG
using ll=long long;
const int N=6e6+10;

int primes[N], st[N], cnt=0; //0为素数
int n; int a[N];

void init()
{
    st[0]=st[1]=1;
    for(int i=2; i<N; i++)
        if(!st[i]) //当前数是素数
        {
            primes[++cnt]=i;
            for(int j=i<<1; j<N; j+=i)
                st[j]=1;
        }
    
}

void solve()
{
    read(n);
    for(int i=1; i<=n; i++) read(a[i]);

    sort(a+1, a+1+n, greater<int>());

    int ans=0;
    ll suma=0, sump=0;
    for(int i=1; i<=n; i++)
    {
        suma+=a[i]; sump+=primes[i];
        if(suma>=sump) ans=i; //满足几个数的题意要求
    }
    quickwrite(n-ans); puts("");
}

// #undef DEBUG
signed main()
{
    #ifdef DEBUG
        freopen("../in.txt", "r", stdin);
        freopen("../out.txt", "w", stdout);
    #endif
    #ifndef quickread
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #endif

    init();

    int T=1; scanf("%d", &T);
    while(T--) 
    {
        solve();
    }
    return 0;
}
